home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2505 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  943 b 

  1. Path: news.gate.net!pslfl2-35
  2. From: bhutto@gate.net (William Hutto)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: ** Array problem **
  5. Date: 21 Jan 1996 12:36:49 GMT
  6. Organization: CyberGate, Inc.
  7. Message-ID: <4dtc11$21r4@news.gate.net>
  8. References: <4dqh8k$ov9@neptunus.pi.net>
  9. NNTP-Posting-Host: pslfl2-35.gate.net
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. bhutto@gate.net (William Hutto) spake:
  13. ;In article <4dqh8k$ov9@neptunus.pi.net>, mv@pi.net spake:
  14. ;;
  15. ;;Hello Bill Wendlig (and everybody else),
  16. <snip>
  17.  
  18. ;;char *s;
  19. ;;char a[20][20];
  20. <snip>
  21.  
  22. ;;    for (i=0; i<=15; i++)
  23. ;;     {
  24. ;;      strcpy(a[i],s);
  25. ;
  26. ;sizeof a[i] = 20, so:
  27. ;
  28. ;22-20 = 2 characters written to a[i+1] which on the last iteration will write 
  29. ;2 characters beyond the end of *a* (illegally). 
  30.  
  31. I should elaborate on this. If i==19, which would be the last array in *a*, it 
  32. would write beyond *a*. The loop above luckily ends before then.
  33.  
  34. Bill
  35.  
  36. "Whatcha got on?...Your mind?"
  37.